package io.github.wangtisnruipopo.carscore.types;

import cn.hutool.core.util.IdUtil;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * <h1>卡牌抽象类</h1>
 *
 * @author wangtianrui
 */
@NoArgsConstructor
public abstract class AbsSimpleCard<D extends AbsDecorValue, V extends AbsCardValue> implements ISimpleCard<D, V> {

    @Getter
    protected String id;
    @Getter
    @Setter
    protected D decor;
    @Getter
    @Setter
    protected V value;

    {
        this.id = IdUtil.fastSimpleUUID();
    }

    /**
     * <h2>判断两张卡牌是否相等</h2>
     *
     * @param o 与之比较的卡牌
     * @return 是否相等，相等返回true，反之返回false
     */
    @Override
    public boolean equals(Object o) {
        if (o == null) return false;
        if (o instanceof AbsSimpleCard) {
            return this.getId().equals(((AbsSimpleCard<?, ?>) o).getId());
        }
        return false;
    }

}
